/**
 * @param {string} time
 * @return {string}
 */
console.log(maximumTime("2?:?0"));

function maximumTime(time) {
    var item = time.split('');
    for (i = 0; i < time.length; i++) {
        if (time.charAt(i) == '?') {
            switch (i) {
                case 0:
                    if (item[1] < 4 || item[1] == '?') { item[0] = 2; } else { item[0] = 1; }


                    break;
                case 1:
                    if (item[0] == 2) {
                        item[1] = 3;
                    } else { item[1] = 9; }

                    break;
                case 3:
                    item[3] = 5;

                    break;
                case 4:
                    item[4] = 9;
                    break;
            }
        }

    }
    return item.join('');

};